package servlet;

import bean.EmpBean;
import dao.impl.EmpDaoImpl;
import service.EmpServiceImpl;
import service.IEmpService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.List;

@WebServlet(name = "ShowAllServlet",value = "/showAll")
public class ShowAllServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        IEmpService iEmpService = new EmpServiceImpl();

        List<EmpBean> list = iEmpService.showAllEmps();

        HttpSession session = request.getSession();

        session.setAttribute("datas",list);

         response.sendRedirect("jsp/show.jsp");


    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
       doPost(request,response);
    }
}
